new Vue({
  el: '#app',
  data() {
    return {
      form1: {
        Article_Name: "",
        Category_SerialNumber: "",
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),
        Type: "0",
        Group_Purchasing_SerialNumber: '',
        token: $.cookie("token"),
        page: 1,			//页数
        limit: 10,			//每页数据条数
      },
      form: {},
      total: 0,
      category: [],
      Enterprise: [],
      Tags: [{
        name: '交易记录',
      }, {
        name: '交易公告',
      }],
      activeindex: 0,
      tableData: [{
        Group_Purchasing_SerialNumber: '',//主键
        Article_SerialNumber: "",//商品主键
        Total_Quantity: "",//总数
        Starting_Quantity: "",//起步量
        Unit_Quantity: "",//单位量
        Amount: "",//总数
        Article_Unit_SerialNumber: "",//商品单位
        Delivery_Time: "",//发货时间
        Trading_Type: "",//交易方式
        Shipment_Type: "",//装运方式
        Transport_Type: "",//运输方式
        Payment_Type: "",//付款方式
        Supplementary_Explanation: '',//补充约定
        Contacts: '',//联系人
        Contacts_Phone: '',//联系人电话
        Picture_URL: '',//商品图片
      }],
      loading: false,
      Enterprise_Info_SerialNumber: $.cookie("enterprise")
    }
  },
  mounted() {
    this.form1.Group_Purchasing_SerialNumber = sessionStorage.getItem('Group_Purchasing_SerialNumber')
    //默认查询第一组数据
    this.getList(this.form1)
    this.getData(this.form1.Group_Purchasing_SerialNumber)
  },
  methods: {
    active(i) {
      this.activeindex = i
    },
    getData(Group_Purchasing_SerialNumber) {
      let _this = this;
      $.ajax({
        url: DomainName + '/getGroupProcureIDAction',
        type: 'POST',
        data: {
          Group_Purchasing_SerialNumber,
          token: $.cookie("token")
        },
        success: function (res) {
          console.log(res)
          _this.form = res.Data
        }
      })
    },
    //通过关键字查询数据
    onSerach() {
      this.getList(this.form1)
    },
    //通过选择类别查询数据
    change(e) {
      this.form1.Category_SerialNumber = e
      this.getList(this.form1)
    },
    //通过选择公司查询数据
    change1(e) {
      this.form1.Enterprise_Info_SerialNumber = e
      this.getList(this.form1)
    },
    //号码按键查询
    handleSizeChange(val) {
      this.form1.page = 1;
      this.form1.limit = val;
      this.getList(this.form1)
    },
    //号码按键查询
    handleCurrentChange(val) {
      this.form1.page = val;
      this.getList(this.form1)
    },
    //分页查询数据
    getList(data) {
      let _this = this
      $.ajax({
        type: 'POST',
        data,
        url: DomainName + '/getGroupTransactionAllAction',
        success: function (Result) {
          console.log(Result)
          _this.total = parseInt(Result.limit)
          _this.tableData = Result.tableData
          _this.tableData.forEach(item => {
            item.Quantity = item.Quantity + item.Article_Unit_SerialNumber
            item.Total_Quantity = item.Total_Quantity + item.Article_Unit_SerialNumber
          })
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      })
    },
  },
})

